from cmath import inf

maxn = 1005
# main
n, m = input().split()
n, m = int(n), int(m) + 1
str = "0" + input()

# n = asiz * anum + bsiz * bnum
asiz = n // m
bsiz = (n + m - 1) // m
bnum = n % m
anum = m - bnum
# print(anum, asiz, bnum, bsiz)

f = [[inf for j in range(maxn)] for i in range(maxn)]
f[0][0] = 0
for i in range(1, m + 1):
    for j in range(min(bnum, i) + 1):
        if j - 1 >= 0 and i - 1 >= 0 and f[i - 1][j - 1] != inf:
            s = (j - 1) * bsiz + (i - 1 - (j - 1)) * asiz + 1
            f[i][j] = min(f[i][j], f[i - 1][j - 1] + int(str[s : s + bsiz]))
        
        if j >= 0 and i - 1 >= 0 and f[i - 1][j] != inf:
            s = j * bsiz + (i - 1 - j) * asiz + 1
            f[i][j] = min(f[i][j], f[i - 1][j] + int(str[s : s + asiz]))
        pass
          
print(f[m][bnum])


